package main

import (
	"fmt"
	"reflect"
)

func main() {
	var MyInterface interface{}

	// 基础类型
	MyInterface = "字符串"
	printNameKind(MyInterface) // Name:string,Kind:string

	// 切片
	MyInterface = []string{""}
	printNameKind(MyInterface) // Name:,Kind:slice

	// 结构体
	type MyStruct struct {
		A int
	}
	MyInterface = MyStruct{}
	printNameKind(MyInterface) // Name:MyStruct,Kind:struct

	// map
	MyInterface = map[string]int{}
	printNameKind(MyInterface) // Name:,Kind:map
}

func printNameKind(param interface{}) {

	Type := reflect.TypeOf(param)
	fmt.Printf("Name:%s,Kind:%+v \n", Type.Name(), Type.Kind())
}
